/**
 * Created by linwei on 2017/6/22.
 */

let ConnectionInfo = require('./connection');
(async ()=>{
  try{
    let connection =await  ConnectionInfo.init();
    exports.code =  connection.define("code",{
      name: {type: 'text'},  //名字
      code: {type: 'text'},  //复活码
      time: {type: 'text'},  //过期时间
      timeStart: {type: 'text'},  //过期时间
    });
    exports.question =  connection.define("question",{
      id: {type: 'integer', key: true,serial:true},
      answer: {type: 'text'},  //题目
      question: {type: 'text'},  //答案
    });

    exports.account =  connection.define("account",{
      id: {type: 'integer', key: true,serial:true},
      account: {type: 'text'},  //账号
      passWord: {type: 'text'},  //密码
      time: {type: 'text'},  //开始时间
      aliveTime: {type: 'text'},  //存活时间
      status: {type: 'text'},  //存活时间
    });

    exports.timeList = connection.define("timeList", {
      id: {type: 'integer', key: true, serial: true},
      status: {type: 'integer'},
      hour: {type: 'text'},  //题目
      min: {type: 'text'},  //答案
      applicationName: {type: 'text'},  //答案
      rewardAmount: {type: 'text'},  //答案
      packageName: {type: 'integer'},  //状态 0：正常 -1 删除
    });

    exports.questionLister = connection.define("questionLister", {
      id: {type: 'integer', key: true, serial: true},
      question: {type: 'text'},  //题目
      answerList: {type: 'text'},  //答案集合
      answer: {type: 'text'},  //答案
      channel: {type: 'text'},  //channel
    });


    exports.app_account = connection.define("app_account", {
      id: {type: 'integer', key: true, serial: true},
      account: {type: 'text'},  //账号
      passWd: {type: 'text'},  //密码
      phone: {type: 'text'},  //电话
      MacId: {type: 'text'},  //MacId
      aliveTime: {type: 'text'},  //vip时间
      time: {type: 'text'},  //VIP参考时间
      createTime: {type: 'text'},  //注册时间
      updateTime: {type: 'text'},  //订单有变化时间
      status: {type: 'integer'},  //状态 0：正常 -1 非vip
      shareTimes: {type: 'integer'},  //分享次数
      golden: {type: 'integer'},  //分享次数
      shareId:{type: 'text'} //分享者id
    });

    exports.app_phone_code = connection.define("app_phone_code", {
      id: {type: 'integer', key: true, serial: true},
      phone: {type: 'text'},  //电话
      code: {type: 'text'},  //code码
      time: {type: 'text'},  //时间
    });

    exports.itemList = connection.define("itemList", {
      id: {type: 'integer', key: true, serial: true},
      name: {type: 'text'},  //商品名称
      time: {type: 'text'},  //时间
      status: {type: 'integer'},  //状态
      totalMoney: {type: 'integer'},  //显示价格
      realMoney: {type: 'integer'},  //实际价格
      type: {type: 'integer'},  //类型 1：vip时间，2 ：金币
    });

    exports.appOrder = connection.define("app_order", {
      id: {type: 'integer', key: true, serial: true},
      accountId: {type: 'text'},  //商品名称
      orderId: {type: 'text'},  //商品名称
      itemId: {type: 'text'},  //时间
      money: {type: 'integer'},  //显示价格
      status: {type: 'integer'},  //实际价格
    });

    exports.channel = connection.define("channel", {
      id: {type: 'integer', key: true, serial: true},
      channel: {type: 'text'},  //渠道
      status: {type: 'integer'},  //状态
    });

    exports.roomInfo = connection.define("roomInfo", {
      id: {type: 'integer', key: true, serial: true},
      type: {type: 'integer'},  //房间类型
      golden: {type: 'integer'},  //需要的金币
      questionNum: {type: 'integer'},  //题目数量
      msg: {type: 'text'},  //描述
    });

    exports.reward = connection.define("reward", {
      id: {type: 'integer', key: true, serial: true},
      startRank: {type: 'integer'},  //开始排名
      endRank: {type: 'integer'},  //结束排名
      type: {type: 'integer'},  // 房间类型
      golden: {type: 'integer'},  //奖励金币
    });

    connection.sync();

  }
  catch(err){
    console.log(err);
  }
})();

